import { createStore, useStore as useVuexStore, Store } from "vuex"
import type {} from "vuex"
import login from "./login/index"
import type { IRootState, StoreType } from "./type"

const store = createStore<IRootState>({
  state() {
    return {
      name: "",
      entireRoles: [],
      entireDepartments: [],
      entireMenus: []
    }
  },
  mutations: {},
  actions: {},
  modules: {
    login
  }
})
export default store
export function useStore(): Store<StoreType> {
  return useVuexStore()
}

export function initStore() {
  store.dispatch("login/initCache")
}
